package shuashuami.hb.com.view;

import android.app.Activity;
import android.app.Dialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import shuashuami.hb.com.hbclient.R;
import shuashuami.hb.com.http.ChangeBUserMessageHttp;

/**
 * Created by Administrator on 2017/6/20.
 */

public class BChangeContentDialog extends Dialog {

    private String type;
    private Activity activity;
    private TextView tvData;

    public BChangeContentDialog(Activity context, String type, TextView tvData) {
        super(context, R.style.Dialog);
        this.activity = context;
        this.type = type;
        this.tvData = tvData;
        setCustomDialog();
    }

    private void setCustomDialog() {
        View mView = LayoutInflater.from(getContext()).inflate(R.layout.dialog_change_content_layout, null);
        TextView tvTitle = (TextView) mView.findViewById(R.id.tv_change_content_title);
        final EditText edtData = (EditText) mView.findViewById(R.id.edt_change_content_data);
        Button btnCancle = (Button) mView.findViewById(R.id.btn_change_content_cancle);
        Button btnEnter = (Button) mView.findViewById(R.id.btn_change_content_enter);
        if (type.equals("realname")) {
            tvTitle.setText("姓名");
        } else if (type.equals("qq")) {
            tvTitle.setText("QQ");
        } else if (type.equals("email")) {
            tvTitle.setText("邮箱");
        } else if (type.equals("mobile")) {
            tvTitle.setText("手机号");
        } else if (type.equals("parent_id")) {
            tvTitle.setText("代理编号");
        }
        btnCancle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        btnEnter.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                changeContent(edtData.getText().toString());
                dismiss();
            }
        });
        super.setContentView(mView);
    }

    private void changeContent(String data) {
        ChangeBUserMessageHttp changeCUserMessageHttp = new ChangeBUserMessageHttp(activity, tvData);
        changeCUserMessageHttp.getMessage(type, data);
    }

    @Override
    public void setContentView(int layoutResID) {
    }

    @Override
    public void setContentView(View view, ViewGroup.LayoutParams params) {
    }

    @Override
    public void setContentView(View view) {
    }
}
